using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Text;

using Liberty.Domain.Kernel;
using Liberty.Persistence.Kernel;

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Tests.PersistenceTests
{
    [TestClass()]
    public class StateBrokerTests : AbstractBrokerTests
    {
        #region Constants
        private const long TEXAS_OID = 51;
        private const string TEXAS_DESCRIPTION = "TX";
        #endregion

        #region Properties
        #endregion

        #region Setup and Teardown
        [TestInitialize()]
        public void SetupStateBrokerTests()
        {
            this.Broker = new StateBroker( this.ConnectionString );
        }

        [TestCleanup()]
        public void TeardownStateBrokerTests()
        {
            this.Broker = null;
        }
        #endregion

        #region Test Methods
        [TestMethod()]
        public void TestAllStates()
        {
            List<State> states = this.Broker.AllStates();
            Assert.IsNotNull( states, "All States should not be null" );
            Assert.AreEqual( states.Count, 59, "Number of States should be 59" );
        }

        [TestMethod()]
        public void TestStateWithOID()
        {
            State texasState = this.Broker.StateWith( TEXAS_OID );
            Assert.IsNotNull( texasState, "Texas state is null" );
            Assert.AreEqual( texasState.Description, "TX", "Should be TX" );
        }

        [TestMethod()]
        public void TestStateWithDescription()
        {
            State texasState = this.Broker.StateWith( TEXAS_DESCRIPTION );
            Assert.IsNotNull( texasState, "Texas state is null" );
            Assert.AreEqual( texasState.Description, "TX", "Should be TX" );
        }
        #endregion

        #region Support Methods
        public StateBroker Broker
        {
            get
            {
                return i_Broker;
            }
            set
            {
                i_Broker = value;
            }
        }
        #endregion

        #region Data Elements
        private StateBroker i_Broker;
        #endregion
    }
}
